package com.lanou.pro;

import java.io.IOException;
import java.net.*;

/**
 * @author zyj
 * @date 2022年06月11日 17:17
 */
public class Send {
    public static void main(String[] args) {
        try {
            //创建UDP套接字对象
            DatagramSocket socket = new DatagramSocket();
            String message = "正在学习网络编程";
            byte buf[] = message.getBytes();
            //创建数据包
            DatagramPacket packet = new DatagramPacket(buf,buf.length, InetAddress.getLocalHost(),80);
            socket.send(packet);
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
